package com.example.myapplication;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.widget.ViewPager2;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

public class test extends Fragment {

    private static final String[] TITLES = {
            "登鹳雀楼", "静夜思", "春晓", "白日依山尽", "黄河远上白云间"
    };

    private static final String[] CONTENTS = {
            "白日依山尽，黄河入海流。\n欲穷千里目，更上一层楼。",
            "床前明月光，疑是地上霜。\n举头望明月，低头思故乡。",
            "春眠不觉晓，处处闻啼鸟。\n夜来风雨声，花落知多少。",
            "白日依山尽，黄河入海流。\n欲穷千里目，更上一层楼。",
            "黄河远上白云间，一片孤城万仞山。\n羌笛何须怨杨柳，春风不度玉门关。"
    };

    private int position;

    public static test newInstance(int position) {
        test fragment = new test();
        Bundle args = new Bundle();
        args.putInt("position", position);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            position = getArguments().getInt("position");
        }
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.testlayout, container, false);

        RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
        recyclerView.setAdapter(new PoemAdapter(TITLES, CONTENTS));

        return view;
    }



}
